package com.tengju.user.domain.shared;


import java.math.BigDecimal;
import java.math.RoundingMode;

public class AmountUtil {

    public static final BigDecimal TEN_THOUSAND = BigDecimal.valueOf(10000L);

    /**
     * >=10000 返回xxW（保留2位小数）  <10000 返回xxx元
     */
    public static String parseToString(BigDecimal amount) {

        if (amount.compareTo(TEN_THOUSAND) >= 0) {
            BigDecimal tenThousandAmount = amount.divide(TEN_THOUSAND, 2, RoundingMode.DOWN);
            return tenThousandAmount.toString() + "W";
        } else {
            return amount.toString() + "元";
        }

    }

}
